package com.justnow.offer;

public class EnumSingleton {

    /**
     * 枚举类型是线程安全的，并且只会装载一次
     */
    private enum Singleton {

        INSTANCE;

        private final EnumSingleton instance;

        Singleton() {
            instance = new EnumSingleton();
        }

        private EnumSingleton getInstance() {
            return instance;
        }
    }

    public static EnumSingleton getInstance() {

        return Singleton.INSTANCE.getInstance();

    }
}
